package com.bjpowernode.shop.exception;


import com.bjpowernode.shop.entity.R;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

//异常过滤器：通知类
@ControllerAdvice
public class CustomerExceptionResolver {

    @ExceptionHandler(RuntimeException.class)
    public ResponseEntity getRuntimeException(RuntimeException e) {
        e.printStackTrace();
        return new ResponseEntity(
                R.builder().code(20401).msg(e.getMessage()).build(),
                HttpStatus.REQUEST_TIMEOUT
        );
    }
}
